package com.frank.yinyuetai.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.frank.yinyuetai.Bean.VideoBean;
import com.frank.yinyuetai.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Administrator on 2016/8/17 0017.
 */
public class DescribeFragment extends Fragment {
    @Bind(R.id.profile_image)
    CircleImageView profileImage;
    @Bind(R.id.artistName)
    TextView artistName;
    @Bind(R.id.play_count)
    TextView playCount;
    @Bind(R.id.play_pc_count)
    TextView playPcCount;
    @Bind(R.id.play_mobile_count)
    TextView playMobileCount;
    @Bind(R.id.describe)
    TextView describe;
    private VideoBean vBean;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.describe_fragment, null);
        ButterKnife.bind(this, view);
        vBean = (VideoBean) getArguments().getSerializable("videoBean");
        initData();
        return view;
    }

    private void initData() {
        Glide.with(this)
                .load(vBean.getArtists().get(0).getArtistAvatar())
                .centerCrop()
                .into(profileImage);
        artistName.setText(vBean.getArtistName());
        playCount.setText("播放次数：" + String.valueOf(vBean.getTotalViews()));
        playPcCount.setText("pc端：" + String.valueOf(vBean.getTotalPcViews()));
        playMobileCount.setText("移动端：" + String.valueOf(vBean.getTotalMobileViews()));
        describe.setText(vBean.getDescription());

    }

    public static DescribeFragment nesInstance(VideoBean videoBean) {
        DescribeFragment fragment = new DescribeFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("videoBean", videoBean);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
